package com.songshuai.webapi.permission.common.enumerations;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public enum SignStatusType {
    ZhengChangShangke(492, "正常上课"),
    XueShengChiDao(493, "学生迟到"),
    XueShengKuangKe(494, "学生旷课"),
    TianQianXiaKe(495, "提前下课"),
    JiaoShiWeiShangKe(496, "教师未上课"),
    KeChengYiChang(497, "课程异常"),
    XueShengTiaoKe(498, "学生调课"),
    JiaoShiWangTianXie(499, "教师忘记填写"),
    XueShengWeiShangKe(500, "学生未上课"),;
    private int code;
    private String msg;

    SignStatusType(int code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public static int getCode(String define){
        try {
            return SignStatusType.valueOf(define).code;
        } catch (IllegalArgumentException e) {
            log.error("undefined error code: {}", define);
            return 0;
        }
    }

    public static String getMsg(String define){
        try {
            return SignStatusType.valueOf(define).msg;
        } catch (IllegalArgumentException e) {
            log.error("undefined error code: {}", define);
            return "";
        }
    }

    public static String getMsg(Integer code){
        if(code==null||code<=0)
            return "";
        for(SignStatusType err : SignStatusType.values()){
            if(err.code==code){
                return err.msg;
            }
        }
        return "";
    }

    public int getCode(){
        return code;
    }

    public String getMsg(){
        return msg;
    }
}
